package cn.tedu;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class Demo06 {
    public static void main(String[] args) {
        //用户手动输入英雄和价格,并且添加到hero表中
        Scanner sc = new Scanner(System.in);
        //接收用户输入的英雄名
        String name = sc.nextLine();
        //接收用户输入的英雄价格
        int money = sc.nextInt();
        try(Connection conn = DBUtils.getConn()) {
            Statement s = conn.createStatement();
            String sql = "insert into hero values (null,'"+name+"',"+money+")";
            s.executeUpdate(sql);
            System.out.println(sql);
            System.out.println("执行完成!");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
